/**
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Autogenerated file -- DO NOT EDIT!

#ifndef ES2PANDA_LSP_CODE_FIX_KIND_H
#define ES2PANDA_LSP_CODE_FIX_KIND_H

#include "util/diagnostic.h"
#include <tuple>

namespace ark::es2panda::lsp::codefixes {

class DiagnosticCode {
public:
    /**
    * Need a numeric type error code to send to the IDE. So, using 'DIAGNOSTIC_CODE_ULTIPLIER*diagnosticType+id' to
    * calculate it. Now all the 'id' are below 1000, so set the multiplier as 1000.
    */
    static constexpr int DIAGNOSTIC_CODE_MULTIPLIER = 1000;

    constexpr DiagnosticCode(util::DiagnosticType type, int id) : type_(type), id_(id) {}

    constexpr int GetCodeNumber() const
    {
        return (static_cast<int>(type_) * DIAGNOSTIC_CODE_MULTIPLIER + id_);
    }

    constexpr bool operator==(const DiagnosticCode &other) const
    {
        return GetCodeNumber() == other.GetCodeNumber();
    }

    constexpr bool operator!=(const DiagnosticCode &other) const
    {
        return !(*this == other);
    }

private:
    util::DiagnosticType type_;
    int id_;
};

template <size_t N>
class CodeFixKind {
public:
    constexpr CodeFixKind(std::array<DiagnosticCode, N> codes, const std::string_view id)
        : diagnosticCodes_(codes), codeFixId_(id)
    {
    }

    constexpr const std::array<DiagnosticCode, N> &GetSupportedCodes() const
    {
        return diagnosticCodes_;
    }

    constexpr std::array<int, N> GetSupportedCodeNumbers() const
    {
        std::array<int, N> codeNumbers {};
        for (size_t i = 0; i < N; ++i) {
            codeNumbers[i] = diagnosticCodes_[i].GetCodeNumber();
        }
        return codeNumbers;
    }

    constexpr std::string_view GetFixId() const
    {
        return codeFixId_;
    }

private:
    std::array<DiagnosticCode, N> diagnosticCodes_;
    std::string_view codeFixId_;
};

% CodeFixRegister::codefix_map.each do |code_fix_id, diag_vec|
static constexpr CodeFixKind<<%= diag_vec.size %>> <%= code_fix_id.snakecase.upcase %> {
    std::array<DiagnosticCode, <%= diag_vec.size %>> {
%   diag_vec.each_with_index do |diag, index|
    DiagnosticCode(util::DiagnosticType::<%= diag.type.to_s.upcase %>, <%= diag.id %>)<%= ',' unless index == diag_vec.size - 1 %>
%   end
    },
    "<%= code_fix_id %>"
};
% end

} // namespace ark::es2panda::lsp::codefixes

#endif // ES2PANDA_LSP_CODE_FIX_KIND_H
